package com.simple.portal.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.simple.base.dao.BaseDAO;
import com.simple.portal.dao.IEnterpriseDAO;
import com.simple.portal.vo.EnterpriseVO;
import com.simple.util.common.Constants;

@Repository("enterpriseDAO")
public class EnterpriseDAOImpl extends BaseDAO implements IEnterpriseDAO {

	
	
	@Override
	public EnterpriseVO findById(final String fiId) {
		return (EnterpriseVO)super.get(EnterpriseVO.class, fiId);
	}

	@Override
	public void save(final EnterpriseVO enterpriseVO,final String operator) {
		EnterpriseVO tempEnterpriseVO = super.save(enterpriseVO);
		super.saveLogger(operator, tempEnterpriseVO, tempEnterpriseVO.getEnterpriseId(),Constants.LOGGER_OPERATE_FLAG_ADD);
	}

	@Override
	public void update(final EnterpriseVO enterpriseVO,final String type,final String operator) {
		super.update(enterpriseVO);
		super.saveLogger(operator, enterpriseVO, enterpriseVO.getEnterpriseId(),type);
	}
	
	@Override
	public List<EnterpriseVO> findAll() {
		return  super.query(EnterpriseVO.class);
	}

	@Override
	public void delete(final EnterpriseVO enterpriseVO,final String operator) {
		super.delete(enterpriseVO);
		super.saveLogger(operator, enterpriseVO, enterpriseVO.getEnterpriseId(), Constants.LOGGER_OPERATE_FLAG_DELETE);
	}

	@Override
	public void delete(final String id,final String operator) {
		EnterpriseVO enterpriseVO = findById(id);
		super.delete(EnterpriseVO.class, id);
		super.saveLogger(operator, enterpriseVO, enterpriseVO.getEnterpriseId(), Constants.LOGGER_OPERATE_FLAG_DELETE);
	}

}
